package com.vstudy.zx.controller;

import com.vstudy.zx.service.MessageService;
import com.vstudy.zx.utils.models.MessageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

// auth
@Controller
@RequestMapping(value = "/message")
public class MessageController {
    @Autowired
    private MessageService service;

    @RequestMapping(value = "/getMessage", method = RequestMethod.POST)
    @ResponseBody
    public Object getMessageByCon(Long conId, HttpServletRequest request) {
        List<MessageModel> msgs = service.getMessageByCon(conId);
        return msgs;
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public Object save(Long conId, String msg, HttpServletRequest request) {
        int rs = service.saveMsg(conId, msg);
        return rs;
    }
}
